---
title: Getting Started
sidebar:
  order: 1
---

import { Tabs, TabItem } from '@astrojs/starlight/components';

## Requirements

Knip v5 requires at least Node.js v18.18.0. Or Bun.

Want to try Knip without installation? Visit [the playground][1].

## Installation

This is the easiest and recommended way to install Knip:

<Tabs syncKey="pm">
  <TabItem label="npm">
    ```shell
    npm init @knip/config
    ```
  </TabItem>

  <TabItem label="pnpm">
    ```shell
    pnpm create @knip/config
    ```
  </TabItem>

  <TabItem label="bun">
    ```shell
    bun create @knip/config
    ```
  </TabItem>

  <TabItem label="yarn">
    ```shell
    yarn create @knip/config
    ```
  </TabItem>
</Tabs>

Now you can run Knip to lint your project:

<Tabs syncKey="pm">
  <TabItem label="npm">
    ```shell
    npm run knip
    ```
  </TabItem>

  <TabItem label="pnpm">
    ```shell
    pnpm knip
    ```
  </TabItem>

  <TabItem label="bun">
    ```shell
    bun knip
    ```
  </TabItem>

  <TabItem label="yarn">
    ```shell
    yarn knip
    ```
  </TabItem>
</Tabs>

Knip will lint your project and report unused dependencies, exports and files.

If the output makes sense to you, feel free to go to the next page:
[configuration][2].

## Too Much?

In large or complex codebases the output might be overwhelming. Start by
limiting the number of shown issues per type:

<Tabs syncKey="pm">
  <TabItem label="npm">
    ```shell
    npm run knip -- --max-show-issues 5
    ```
  </TabItem>

  <TabItem label="pnpm">
    ```shell
    pnpm knip --max-show-issues 5
    ```
  </TabItem>

  <TabItem label="bun">
    ```shell
    bun knip --max-show-issues 5
    ```
  </TabItem>

  <TabItem label="yarn">
    ```shell
    yarn knip --max-show-issues 5
    ```
  </TabItem>
</Tabs>

The output is easier to digest and may include some configuration hints to get
an idea of what's left to configure. Many unused files? Go to [configuration][2]
and follow up with [troubleshooting][3] if needed.

:::tip

Do not use the `ignore` option just to get rid of unwanted output. Read
[Configuring Project Files][4] to get the most out of Knip.

:::

## Manual

Alternatively, manually install Knip using your package manager:

<Tabs syncKey="pm">
  <TabItem label="npm">
    ```shell
    npm install -D knip typescript @types/node
    ```
  </TabItem>

  <TabItem label="pnpm">
    ```shell
    pnpm add -D knip typescript @types/node
    ```
  </TabItem>

  <TabItem label="bun">
    ```shell
    bun add -D knip typescript @types/node
    ```
  </TabItem>

  <TabItem label="yarn">
    ```shell
    yarn add -D knip typescript @types/node
    ```
  </TabItem>
</Tabs>

Knip uses `typescript` and ` @types/node` as peer dependencies to increase
compatibility with your project. No worries, they're probably in your
`node_modules` already.

Then add a `knip` script to your `package.json`:

```json title="package.json"
{
  "name": "my-project",
  "scripts": {
    "knip": "knip"
  }
}
```

## Without installation

To run Knip without adding it to your project:

<Tabs syncKey="pm">
  <TabItem label="npm">
    ```shell
    npx knip
    ```
  </TabItem>

  <TabItem label="pnpm">
    ```shell
    pnpm dlx knip
    ```
  </TabItem>

  <TabItem label="bun">
    ```shell
    bunx knip
    ```
  </TabItem>
</Tabs>

In this scenario `typescript` and `@types/node` are expected to be installed
already.

[1]: /playground
[2]: ./configuration.md
[3]: ../guides/troubleshooting.md
[4]: ../guides/configuring-project-files.md
